package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DsKz;
import com.ruoyi.system.service.IDsKzService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 课组信息Controller
 * 
 * @author tyro
 * @date 2025-03-05
 */
@RestController
@RequestMapping("/system/kz")
public class DsKzController extends BaseController
{
    @Autowired
    private IDsKzService dsKzService;

    /**
     * 查询课组信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:kz:list')")
    @GetMapping("/list")
    public TableDataInfo list(DsKz dsKz)
    {
        startPage();
        List<DsKz> list = dsKzService.selectDsKzList(dsKz);
        return getDataTable(list);
    }

    /**
     * 导出课组信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:kz:export')")
    @Log(title = "课组信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DsKz dsKz)
    {
        List<DsKz> list = dsKzService.selectDsKzList(dsKz);
        ExcelUtil<DsKz> util = new ExcelUtil<DsKz>(DsKz.class);
        util.exportExcel(response, list, "课组信息数据");
    }

    /**
     * 获取课组信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:kz:query')")
    @GetMapping(value = "/{kzId}")
    public AjaxResult getInfo(@PathVariable("kzId") Long kzId)
    {
        return success(dsKzService.selectDsKzByKzId(kzId));
    }

    /**
     * 新增课组信息
     */
    @PreAuthorize("@ss.hasPermi('system:kz:add')")
    @Log(title = "课组信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DsKz dsKz)
    {
        return toAjax(dsKzService.insertDsKz(dsKz));
    }

    /**
     * 修改课组信息
     */
    @PreAuthorize("@ss.hasPermi('system:kz:edit')")
    @Log(title = "课组信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DsKz dsKz)
    {
        return toAjax(dsKzService.updateDsKz(dsKz));
    }

    /**
     * 删除课组信息
     */
    @PreAuthorize("@ss.hasPermi('system:kz:remove')")
    @Log(title = "课组信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{kzIds}")
    public AjaxResult remove(@PathVariable Long[] kzIds)
    {
        return toAjax(dsKzService.deleteDsKzByKzIds(kzIds));
    }
}
